package marsrovers;

class OrientationHelper {
	
	public static Orientation getNewOrientation(Orientation o, Instruction i) {
		switch(o) {
			case NORTH: 
				return i == Instruction.L ? Orientation.WEST : Orientation.EAST;
			case EAST: 
				return i == Instruction.L ? Orientation.NORTH : Orientation.SOUTH;
			case WEST: 
				return i == Instruction.L ? Orientation.SOUTH : Orientation.NORTH;
			case SOUTH: 
				return i == Instruction.L ? Orientation.EAST : Orientation.WEST;
			default:
				throw new RuntimeException(
						"Error getting new Orentation from Orientation " 
						+ o.toString() 
						+ ", and Instruction: " 
						+ i.toString());
		}
	}

}
